#ifndef _SESSION_MGR_CONFIGMANAGER_H
#define _SESSION_MGR_CONFIGMANAGER_H

#include <map>
#include <string>

#include "ConfigGenerator.h"

namespace session_mgr
{
    namespace detail
    {
        template <typename Generator>
        inline ConfigGeneratorPtr makeConfigGenerator()
        {
            return ConfigGeneratorPtr(new Generator);
        }
    }
    
    class ConfigManager
    {
        MARK_NONCOPYABLE(ConfigManager);
    public:
        ConfigManager(): generators() {}
        
        template <typename Generator>
        bool registerGenerator(std::string const& name)
        {
            return generators.insert(std::make_pair(name, detail::makeConfigGenerator<Generator>)).second;
        }
        
        ConfigGeneratorPtr getGenerator(std::string const& name);
        
    private:
        typedef ConfigGeneratorPtr (*configGeneratorMaker)();
        
        std::map<std::string, configGeneratorMaker> generators;
    };
}

#endif
